jQuery.expr[':'].regex = function(elem, index, match) {
    var matchParams = match[3].split(','),
        validLabels = /^(data|css):/,
        attr = {
            method: matchParams[0].match(validLabels) ? 
                        matchParams[0].split(':')[0] : 'attr',
            property: matchParams.shift().replace(validLabels,'')
        },
        regexFlags = 'ig',
        regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
    return regex.test(jQuery(elem)[attr.method](attr.property));
}

var ImageServices = {
  loadThumbnails: function () {
    $("a:regex(href, twitpic.com)").each(function () {
      var url = $(this).attr('href');
      var thumbnailUrl = ImageServices.twitpic(url);
      $(this).append("<img src=\"" + thumbnailUrl + "\"></img>");
    });
  },

  twitpic: function (url) {
    var id = url.match(/[a-z0-9]+$/);
    return "http://twitpic.com/show/mini/" + id; 
  },
}

